﻿namespace ExcelTool {
    using System.IO;
    using System.Text;
    using System.Runtime.Serialization.Formatters.Binary; 
    using System;
    public partial class Converter{
        bool binary_format = false;
        private void WriteText(string path, string content) {
            if(File.Exists(path)) {
                FileInfo fi = new FileInfo(path);
                fi.Attributes = FileAttributes.Normal;
                File.Delete(path);
            }

            if (binary_format)
            {
                FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write);
                BinaryFormatter bf = new BinaryFormatter();
                bf.Serialize(fs, ' ');
                fs.Close();
            }
            else
            {
                byte[] bytes = Encoding.UTF8.GetBytes(content);
                FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write);
                fs.Write(bytes, 0, bytes.Length);
                fs.Flush();
                fs.Close();
            }

        }
    }
}
